package thread;

import java.util.Scanner;

public class SleepDemo {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        System.out.println("请输入一个大于0的整数：");

        int i = scanner.nextInt();
        while (true){

            if (i<=0){

                System.out.println("输入有误，请按照提示输入，请输入一个大于0的整数：");
                i = scanner.nextInt();
            }else break;
        }

        while (i>0){
            System.out.println("倒计时剩余："+i+"秒");
            i--;
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("OK");


    }
}
